Skip to content

perf(ai): stream Gemini prompt responses#564

Closed
JustYannicc wants to merge 71 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-gemini-prompt-streaming
Closed

perf(ai): stream Gemini prompt responses#564
JustYannicc wants to merge 71 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-gemini-prompt-streaming

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Switched single-prompt Gemini requests from generateContent to streamGenerateContent?alt=sse.
  • Reused Gemini SSE text extraction for chat and prompt flows while keeping prompt-only no-text errors.
  • Added a focused synthetic SSE regression harness for Gemini prompt streaming.

Why

Gemini prompt calls were buffering the full provider response before yielding a single chunk, delaying first visible output for AI ask, cursor prompt, prompt-window, Raycast AI ask, and transcript correction paths.

Compatibility impact

Final joined text and no-text error messages are preserved. The only intended user-visible change is improved provider chunk cadence and lower first-token latency for Gemini prompt responses.

How tested

  • node --test scripts/test-ai-provider-gemini-prompt-streaming.mjs
  • node --test scripts/test-ai-stream-ipc-batching.mjs
  • node scripts/test-ai-chat-stream-batching.mjs
  • node --test scripts/test-cursor-prompt-stream-batching.mjs
  • node --test scripts/test-use-ai-stream-batching.mjs
  • pnpm exec tsc -p tsconfig.main.json
  • Codex LSP diagnostics on src/main/ai-provider.ts: no diagnostics found

Performance evidence

Synthetic Gemini SSE harness diagnostics showed legacy generateContent buffered 75 bytes before first yield, while streamGenerateContent yielded after 66 of 179 SSE bytes and before response end. The new regression also asserts incremental first-chunk delivery, final joined text equivalence, and preserved no-text errors.

Stack validation

Started from fork/codex/perf-consolidated-integration-stack at 264fb89dc5c867d6c3d77bc4b95e26e235e326ea. Implementation branch: codex/perf-gemini-prompt-streaming.

Replaces

None

…ated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/hooks/use-cached-promise.ts
…ated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime-renderers.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
…ated-integration-stack

# Conflicts:
#	src/renderer/src/CameraExtension.tsx
…ated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime.tsx
… into codex/perf-consolidated-integration-stack
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated lifecycle/media wave-2 PR: #575

@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by #575.

@JustYannicc JustYannicc closed this Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant